package com.lysj.merchant.management.repository;


import com.lysj.admin.utils.spring.foundation.base.BaseRepository;
import com.lysj.admin.utils.web.SelectItem;
import com.lysj.merchant.management.domain.User;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author zk
 * @description 用户表数据处理层
 * @create 2018-07-25 15:02:19
 **/
public interface UserRepository extends BaseRepository<User> {

    User findByUsername(String username);

    User findByPhone(String phone);

    /**
     * 根据商户id和用户类型查询商户管理账户
     */
    User findByMerchantIdAndUserType(String merchantId,Integer userType);

    /**
     * 商户下拉框
     */
    @Query("select new com.lysj.admin.utils.web.SelectItem(u.id,u.name) from User u where u.storeId is null and u.delFlag=1 ")
    List<SelectItem> selectItem();


    /**
     * 根据门店id获取店长信息
     */
    List<User> findByStoreIdAndUserTypeAndDelFlag(String storeId,Integer userType,Integer delFlag);

}